<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;

        }
         .btn{
             width: 100px;
             height: 30px;
             overflow: hidden;
             margin: 50px auto;
             background: chartreuse;
             color: #fff;
             text-align: center;
             line-height: 30px;
             position: relative;
         }

        @keyframes scrd{
            0%{
                transform: scale(0);
            }
            50%{
                transform: scale(25);
            }
            100%{
                transform: scale(50);
            }
        }
        @keyframes scrd{
            0%{
                transform: scale(0);
            }
            50%{
                transform: scale(25);
            }
            100%{
                transform: scale(50);
            }
        }
    </style>
</head>
<body>
    <div class="btn">点击
        <!-- <div class="cirle"></div> -->
    </div>
    <script>
        createEle('.btn')
        var btn = document.querySelector('.btn');
        btn.onclick = function(e){
        //    console.log('click me ')
        //    var px = e.offsetX;
        //    var py = e.offsetY;
        //    cirle.style.left = px - 2 + "px";
        //    cirle.style.top  = py - 2 + "px";
        //    cirle.style.display = 'block';
        //    cirle.style.animation = '.2s scrd';
        //    setTimeout(function(){
        //     cirle.style.animation = '';
        //     cirle.style.display = 'none';
        //    },200)
        }
        function createEle(ele){
            var ele = document.querySelector(ele);
            if (ele == null) {
                return false
            }
            var box = document.createElement('div');
            box.className = "cirle";
            box.style = 'display:none;width:4px;height:4px;border-radius:50%;overflow:hidden;position:absolute;background-color:rgba(0,0,0,.3)'
            ele.appendChild(box)
            ele.addEventListener('click',function(e){
                var cirle = document.querySelector('.cirle');
                var px = e.offsetX;
                var py = e.offsetY;
                cirle.style.left = px - 2 + "px";
                cirle.style.top  = py - 2 + "px";
                cirle.style.display = 'block';
                cirle.style.animation = '.2s scrd';
                setTimeout(function(){
                    cirle.style.animation = '';
                    cirle.style.display = 'none';
                },200)
            },true)
        }
    </script>
</body>
</html>